<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<body>
    <form class="layui-form layui-form-pane" id="operatePage">
        <div class="page-title">
            <div class="page-title-con">
                <span>重置密码</span>
                <div class="move_title"></div>
                <?php include "../public/sub.php";?>
            </div>
        </div>

        <div class="main-container">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" id="realname" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>新密码</label>
                        <div class="layui-input-block">
                            <input type="text" name="pass" id="pass" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>确认密码</label>
                        <div class="layui-input-block">
                            <input type="text" name="passcon" id="passcon" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
<script>
    var param_id = getQueryVariable('id') || 0;
    $("#operatePage").validate({
        rules: {
            pass: {required: true},
            passcon: {required: true},
        },
        messages:{
            pass: {required: "请输入"},
            passcon: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        // render_input_attr();
        facade.ajax({type: 'get', url: ask_user_setpass, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#realname").val(data.realname);
                render_from();
            }
        });

        form.on('submit(add)', function(data){
            var validRes = $("#operatePage").valid();
            if(!validRes){return false;}

            data.field.id = param_id;
            facade.ajax({url: ask_user_setpass, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
